package com.thinker.loan.consumer.service.processor;


import com.thinker.loan.consumer.model.LoanApplicationRequest;
import com.thinker.loan.consumer.enumeration.LoanStatus;
import com.thinker.loan.consumer.service.strategy.ApprovalStrategy;
import com.thinker.loan.consumer.service.CreditService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class CreditCheckProcessor extends AbstractLoanProcessor {
    private final CreditService creditService;
    private final ApprovalStrategy strategy;

    @Override
    public void process(LoanApplicationRequest request) {
        request.setCreditScore(creditService.getCreditScore(request.getCustomer()));
        request.setStatus(LoanStatus.CREDIT_CHECKED);

        strategy.evaluate(request);
    }
}
